package com.fxcalibre.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class Preferences extends Properties
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static Preferences prefs;

	private Preferences()
	{
		try
		{
			load(new FileInputStream("preferences.properties"));
		} catch (FileNotFoundException e)
		{

			try
			{
				put(Constants.KEY_DB_FILE, System.getProperty("user.dir"));
				store(new FileOutputStream(new File("preferences.properties")), "my interesting comment");
			} catch (IOException e1)
			{
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		} catch (IOException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
//		Properties props = new Properties();  
//		props.setProperty("name", "value");  
//		try
//		{
//			props.store(new FileOutputStream(new File("pref.properties")), "my interesting comment");
//		} catch (Exception e)
//		{
//			e.printStackTrace();
//		} 
		
	}

	public static Preferences getPreferences()
	{
		if (prefs == null)
		{
			prefs = new Preferences();
		}

		return prefs;
	}

}
